package br.com.examCertification;

import java.util.List;

import br.com.examCertification.dao.DataManager;
import br.com.examCertification.model.Pergunta;
import br.com.examCertification.model.TipoCertificacao;
import br.com.examCertification.model.TipoExame;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListaExames extends Activity {
	
	private DataManager dataManager;
	
    ListView listaExames;

    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.exames);
        dataManager = DataManagerFactory.getInstance(this);
        
        Bundle extras = getIntent().getExtras();         
        List<TipoExame> tiposExames = (List<TipoExame>) dataManager.getTipoExameListById(extras.getLong("id"));  
        
        
        listaExames = (ListView) findViewById(R.id.listTipoExames);
        listaExames.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, tiposExames));
        listaExames.setTextFilterEnabled(true);    
        listaExames.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent i = new Intent(ListaExames.this,  PreStartExame.class);  
				TipoExame tipoExame = dataManager.getTipoExameList().get(arg2);
                i.putExtra("id", tipoExame.getId());  
                startActivity(i); 
			}
         });
     }
}
 